//
//  GuideCollectionViewCell1.m
//  habit
//
//  Created by huck on 2017/4/18.
//  Copyright © 2017年 custom. All rights reserved.
//

#import "GuideCollectionViewCell.h"
#import "AppUtils.h"
#import "UIView+Response.h"
#import "GuideViewController.h"

@interface GuideCollectionViewCell()

@property (nonatomic, strong) NSTimer *timer;
@property (nonatomic, strong) NSArray *viewArray;

@end

@implementation GuideCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self){
        // 初始化时加载collectionCell.xib文件
        self = [[[NSBundle mainBundle] loadNibNamed:@"GuideCollectionViewCell" owner:self options:nil] firstObject];
        [self initSubview];
    }
    return self;
}

-(void)initSubview
{
    _viewArray = @[_pageView1,_pageView2,_pageView3];
    
}

- (void)dealloc
{
    [AppUtils invalidateTimer:_timer];
}

//开启旅程按钮
- (IBAction)entryBtnClick:(UIButton *)sender
{
    UIViewController *controller = self.responderController;
    if([controller isKindOfClass:GuideViewController.class]){
        [((GuideViewController *)controller) hideGuideView];
    }
}

-(void)setContent
{
    [AppUtils invalidateTimer:_timer];
    for (int i=0;i<_viewArray.count;i++) {
        UIView *pageView = _viewArray[i];
        pageView.hidden = i!= _rowIndex;
        
//        UILabel *l = [pageView viewWithTag:100];//演示代码可删掉
//        l.hidden = YES;
//        l.text = [AppUtils toStr:i];////演示代码可删掉
//        l.transform = CGAffineTransformIdentity;//动效还原//演示代码可删掉
    }
}

//需要动效时在这里打开入口
-(void)beginAnimation
{
//    UIView *pageView = _viewArray[_rowIndex];
//    UILabel *l = [pageView viewWithTag:100];
//    l.transform = CGAffineTransformIdentity;//动效还原
//    [AppUtils invalidateTimer:_timer];
//
//    //实际动画用timer做可以随时关闭
//    [UIView animateWithDuration:0.3 animations:^{
//        l.transform = CGAffineTransformScale(l.transform, 0.6, 2);
//    } completion:^(BOOL finished) {
//        [UIView animateWithDuration:0.3 animations:^{
//            l.transform = CGAffineTransformIdentity;
//        }];
//    }];
}

@end
